package com.tqjc.system.common.enums;

import com.tqjc.system.common.constant.AddTaskConstant;
import com.tqjc.system.common.constant.ConfigConstant;
import com.tqjc.system.common.constant.GlobalConstant;
import com.tqjc.system.common.enums.methods.RefreshConfigCacheService;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;
import lombok.NoArgsConstructor;

/**
 * @description: 配置缓存枚举
 * @Author: 86195
 * @Date: 2024/3/5 8:37
 **/
@NoArgsConstructor
@AllArgsConstructor
@Getter
public enum ConfigCacheEnum implements RefreshConfigCacheService {

    TANKCAR_SCAN_USE_FLAG(ConfigConstant.CONFIG_TYPE_SWITCH,ConfigConstant.CONFIG_ID_TANK_CAR_SCAN,"是否启用槽车扫描开关"){
        @Override
        public void refreshCache(Object value) {
            AddTaskConstant.TANKCAR_SCAN_USE_FLAG = (boolean) value;
        }
    },

    CAR_STATUS_FLAG(ConfigConstant.CONFIG_TYPE_SWITCH,ConfigConstant.CONFIG_ID_CAR_STATUS,"是否检查天车状态开关") {
        @Override
        public void refreshCache(Object value) {
            AddTaskConstant.CAR_STATUS_FLAG = (boolean) value;
        }
    },

    VISIT_MODEL_FLAG(ConfigConstant.CONFIG_TYPE_SWITCH,ConfigConstant.CONFIG_ID_VISIT_FLAG,"是否启参观模式开关") {
        @Override
        public void refreshCache(Object value) {
            GlobalConstant.VISIT_MODEL_FLAG = (boolean) value;
        }
    };
    private String configType;

    private String configId;

    private String desc;


    public static ConfigCacheEnum getConfigCacheEnum(String configId,String configType){
        for (ConfigCacheEnum value : ConfigCacheEnum.values()) {
            if(value.configId.equals(configId) && value.configType.equals(configType)){

                return value;
            }

        }
        return null;
    }
}
